package com.zeratul.common.satoken.inter;

import cn.dev33.satoken.interceptor.SaInterceptor;
import com.zeratul.web.interceptor.base.BaseHandlerInterceptor;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

public class SaDelegateInterceptor extends BaseHandlerInterceptor {

    private SaInterceptor saInterceptor = new SaInterceptor();

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return saInterceptor.preHandle(request, response, handler);
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        saInterceptor.postHandle(request, response, handler, modelAndView);
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        saInterceptor.afterCompletion(request, response, handler, ex);
    }

    /**
     * 拦截器的拦截Path路径
     *
     * @return
     */
    @Override
    public String path() {
        return "/**";
    }
}
